package controller

import (
	"context"
	"lot_admin_api/api"
	"lot_admin_api/internal/model"
	"lot_admin_api/internal/service"
)

var Site = cSite{}

type cSite struct{}

// AddSiteReq  添加站点
func (h *cSite) AddSiteReq(ctx context.Context, req *api.AddSiteReq) (res *model.SiteIdRes, err error) {
	Id, err := service.Site().AddSiteReq(ctx, req)
	res = &model.SiteIdRes{
		Id: Id,
	}
	return res, err
}

// EditSite  编辑站点
func (h *cSite) EditSite(ctx context.Context, req *api.EditSiteReq) (res *model.SiteIdRes, err error) {
	Id, err := service.Site().EditSite(ctx, req)
	res = &model.SiteIdRes{
		Id: Id,
	}
	return res, err
}

// SiteInfo 通过id查询站点
func (h *cSite) SiteInfo(ctx context.Context, req *api.SiteInfoReq) (res *model.SiteDbRes, err error) {
	res, err = service.Site().SearchSiteInfo(ctx, req.Id)
	return res, err
}

// DeleteSite 通过id删除站点
func (h *cSite) DeleteSite(ctx context.Context, req *api.DeleteSiteReq) (res *model.SiteIdRes, err error) {
	res, err = service.Site().DeleteSite(ctx, req.Id)
	return res, err
}

// SiteList 获取站点列表
func (h *cSite) SiteList(ctx context.Context, req *api.SiteListReq) (res *model.SiteListPageRes, err error) {
	res, err = service.Site().SiteList(ctx, req.SiteSearchList)
	return res, err
}
